var fs = require("fs");
var crypto = require("crypto");
module.exports = {
  encrypt: function(str, algorithm, secret) {
    var cipher = crypto.createCipher("aes192", secret);
    var enc = cipher.update(str, "utf8", "hex");
    enc += cipher.final("hex")
    return enc;
  },
  decrypt: function(str, algorithm, secret) {
    var decipher = crypto.createDecipher(algorithm, secret);
    var dec = decipher.update(str, "hex", "utf8");
    dec += decipher.final("utf8");
    return dec;
  },
  encryptFile: function(filename) {
    fs.readFile(filename, "utf-8",function (err, data) {
      var enc = module.exports.encrypt(data, module.exports.secret);
      fs.writeFileSync("./zd.jse",enc);
    });
  }
}
